package gui.view.drawers.editor;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.util.*;

import com.nightpiter.model.objects.*;

import model.MetroModel;
import model.objects.EdiStation;
import model.objects.EdiTunnel;

public abstract class AbstractDrawer implements EditorsDrawer{
	
	protected double scale;
	protected float xTranslate=0, yTranslate=0;
	protected boolean showNames;
	
	@Override
	public void draw(List<EdiStation> stationSelection, List<EdiTunnel> tunnelSelection, Graphics g, boolean showStationNames) {
		showNames = showStationNames;
		MetroModel model = MetroModel.getInstance();
		
		((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);
		
		for(EdiTunnel t:model.getTunnels()) {
			draw(t,g);
		}
		for(Tunnel t:tunnelSelection) {
			drawSelectedTunnel(t,g);
		}
		for(Transfer t:model.getTransfers()) {
			draw(t,g);
		}			

		for(EdiStation station: model) {
			draw(station,g);
		}
		
		for(Station station: stationSelection) {
			this.drawSelectedStation(station,g);
		}
	}
	
	public void shift(int dx, int dy) {
		this.xTranslate+=dx;
		this.yTranslate+=dy;
	}
	
		
	//-------------------------------
	private static Stroke stroke;
	private static Color color;
	private static Paint paint;
	
	public static void saveGrpahicsParam(Graphics g) {
		stroke = ((Graphics2D)g).getStroke();
		color = g.getColor();
		paint = ((Graphics2D)g).getPaint();
	}
	public static void restoreGraphicsParam(Graphics g) {
		((Graphics2D)g).setStroke(stroke);
		g.setColor(color);
		((Graphics2D)g).setPaint(paint);
	}	
	
	
}
